package com.sywl.glzh.web.admin;

import com.sywl.glzh.domain.About;
import com.sywl.glzh.domain.Click;
import com.sywl.glzh.domain.Contact;
import com.sywl.glzh.domain.Information;
import com.sywl.glzh.domain.News;
import com.sywl.glzh.domain.Product;
import com.sywl.glzh.domain.ProductType;
import com.sywl.glzh.domain.Service;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.core.convert.converter.Converter;
import org.springframework.format.FormatterRegistry;
import org.springframework.format.support.FormattingConversionServiceFactoryBean;
import org.springframework.roo.addon.web.mvc.controller.converter.RooConversionService;

@Configurable
/**
 * A central place to register application converters and formatters. 
 */
@RooConversionService
public class ApplicationConversionServiceFactoryBean extends FormattingConversionServiceFactoryBean {

	@SuppressWarnings("deprecation")
	@Override
	protected void installFormatters(FormatterRegistry registry) {
		super.installFormatters(registry);
		// Register application converters and formatters
	}

	public Converter<About, String> getAboutToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.sywl.glzh.domain.About, java.lang.String>() {
            public String convert(About about) {
                return new StringBuilder().append(about.getContent()).append(" ").append(about.getEnContent()).toString();
            }
        };
    }

	public Converter<Long, About> getIdToAboutConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.sywl.glzh.domain.About>() {
            public com.sywl.glzh.domain.About convert(java.lang.Long id) {
                return About.findAbout(id);
            }
        };
    }

	public Converter<String, About> getStringToAboutConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.sywl.glzh.domain.About>() {
            public com.sywl.glzh.domain.About convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), About.class);
            }
        };
    }

	public Converter<Click, String> getClickToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.sywl.glzh.domain.Click, java.lang.String>() {
            public String convert(Click click) {
                return new StringBuilder().append(click.getHits()).toString();
            }
        };
    }

	public Converter<Long, Click> getIdToClickConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.sywl.glzh.domain.Click>() {
            public com.sywl.glzh.domain.Click convert(java.lang.Long id) {
                return Click.findClick(id);
            }
        };
    }

	public Converter<String, Click> getStringToClickConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.sywl.glzh.domain.Click>() {
            public com.sywl.glzh.domain.Click convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), Click.class);
            }
        };
    }

	public Converter<Contact, String> getContactToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.sywl.glzh.domain.Contact, java.lang.String>() {
            public String convert(Contact contact) {
                return new StringBuilder().append(contact.getContent()).append(" ").append(contact.getEnContent()).toString();
            }
        };
    }

	public Converter<Long, Contact> getIdToContactConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.sywl.glzh.domain.Contact>() {
            public com.sywl.glzh.domain.Contact convert(java.lang.Long id) {
                return Contact.findContact(id);
            }
        };
    }

	public Converter<String, Contact> getStringToContactConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.sywl.glzh.domain.Contact>() {
            public com.sywl.glzh.domain.Contact convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), Contact.class);
            }
        };
    }

	public Converter<Information, String> getInformationToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.sywl.glzh.domain.Information, java.lang.String>() {
            public String convert(Information information) {
                return new StringBuilder().append(information.getName()).append(" ").append(information.getEnName()).append(" ").append(information.getLength()).append(" ").append(information.getFormat()).toString();
            }
        };
    }

	public Converter<Long, Information> getIdToInformationConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.sywl.glzh.domain.Information>() {
            public com.sywl.glzh.domain.Information convert(java.lang.Long id) {
                return Information.findInformation(id);
            }
        };
    }

	public Converter<String, Information> getStringToInformationConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.sywl.glzh.domain.Information>() {
            public com.sywl.glzh.domain.Information convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), Information.class);
            }
        };
    }

	public Converter<News, String> getNewsToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.sywl.glzh.domain.News, java.lang.String>() {
            public String convert(News news) {
                return new StringBuilder().append(news.getName()).append(" ").append(news.getEnName()).append(" ").append(news.getContent()).append(" ").append(news.getEnContent()).toString();
            }
        };
    }

	public Converter<Long, News> getIdToNewsConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.sywl.glzh.domain.News>() {
            public com.sywl.glzh.domain.News convert(java.lang.Long id) {
                return News.findNews(id);
            }
        };
    }

	public Converter<String, News> getStringToNewsConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.sywl.glzh.domain.News>() {
            public com.sywl.glzh.domain.News convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), News.class);
            }
        };
    }

	public Converter<Product, String> getProductToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.sywl.glzh.domain.Product, java.lang.String>() {
            public String convert(Product product) {
                return new StringBuilder().append(product.getName()).append(" ").append(product.getEnName()).append(" ").append(product.getImage()).append(" ").append(product.getRemark()).toString();
            }
        };
    }

	public Converter<Long, Product> getIdToProductConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.sywl.glzh.domain.Product>() {
            public com.sywl.glzh.domain.Product convert(java.lang.Long id) {
                return Product.findProduct(id);
            }
        };
    }

	public Converter<String, Product> getStringToProductConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.sywl.glzh.domain.Product>() {
            public com.sywl.glzh.domain.Product convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), Product.class);
            }
        };
    }

	public Converter<ProductType, String> getProductTypeToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.sywl.glzh.domain.ProductType, java.lang.String>() {
            public String convert(ProductType productType) {
                return new StringBuilder().append(productType.getName()).append(" ").append(productType.getEnName()).toString();
            }
        };
    }

	public Converter<Long, ProductType> getIdToProductTypeConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.sywl.glzh.domain.ProductType>() {
            public com.sywl.glzh.domain.ProductType convert(java.lang.Long id) {
                return ProductType.findProductType(id);
            }
        };
    }

	public Converter<String, ProductType> getStringToProductTypeConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.sywl.glzh.domain.ProductType>() {
            public com.sywl.glzh.domain.ProductType convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), ProductType.class);
            }
        };
    }

	public Converter<Service, String> getServiceToStringConverter() {
        return new org.springframework.core.convert.converter.Converter<com.sywl.glzh.domain.Service, java.lang.String>() {
            public String convert(Service service) {
                return new StringBuilder().append(service.getContent()).append(" ").append(service.getEnContent()).toString();
            }
        };
    }

	public Converter<Long, Service> getIdToServiceConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.Long, com.sywl.glzh.domain.Service>() {
            public com.sywl.glzh.domain.Service convert(java.lang.Long id) {
                return Service.findService(id);
            }
        };
    }

	public Converter<String, Service> getStringToServiceConverter() {
        return new org.springframework.core.convert.converter.Converter<java.lang.String, com.sywl.glzh.domain.Service>() {
            public com.sywl.glzh.domain.Service convert(String id) {
                return getObject().convert(getObject().convert(id, Long.class), Service.class);
            }
        };
    }

	public void installLabelConverters(FormatterRegistry registry) {
        registry.addConverter(getAboutToStringConverter());
        registry.addConverter(getIdToAboutConverter());
        registry.addConverter(getStringToAboutConverter());
        registry.addConverter(getClickToStringConverter());
        registry.addConverter(getIdToClickConverter());
        registry.addConverter(getStringToClickConverter());
        registry.addConverter(getContactToStringConverter());
        registry.addConverter(getIdToContactConverter());
        registry.addConverter(getStringToContactConverter());
        registry.addConverter(getInformationToStringConverter());
        registry.addConverter(getIdToInformationConverter());
        registry.addConverter(getStringToInformationConverter());
        registry.addConverter(getNewsToStringConverter());
        registry.addConverter(getIdToNewsConverter());
        registry.addConverter(getStringToNewsConverter());
        registry.addConverter(getProductToStringConverter());
        registry.addConverter(getIdToProductConverter());
        registry.addConverter(getStringToProductConverter());
        registry.addConverter(getProductTypeToStringConverter());
        registry.addConverter(getIdToProductTypeConverter());
        registry.addConverter(getStringToProductTypeConverter());
        registry.addConverter(getServiceToStringConverter());
        registry.addConverter(getIdToServiceConverter());
        registry.addConverter(getStringToServiceConverter());
    }

	public void afterPropertiesSet() {
        super.afterPropertiesSet();
        installLabelConverters(getObject());
    }
}
